package org.zjsru.order.service;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.zjsru.order.pojo.Product;

@FeignClient(
        name = "product-service",
        fallback = ProductFeignClientFallback.class  // 指定降级类
)
public interface ProductFeignClient {
    
    @GetMapping("/products/{id}")
    Product getProductById(@PathVariable("id") Long productId);
    
    @PostMapping("/products/{id}/stock/decrease")
    boolean decreaseStock(
            @PathVariable("id") Long productId,
            @RequestParam("quantity") Integer quantity
    );
    
    @PostMapping("/products/{id}/stock/increase")
    boolean increaseStock(
            @PathVariable("id") Long productId,
            @RequestParam("quantity") Integer quantity
    );
    
    @PostMapping("/product/deduct")
    String deductStock(
            @RequestParam("productId") String productId,
            @RequestParam("count") int count
    );
}